<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5                                                          |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License,        |
// | that is available at http://www.php.net/license/3_0.txt.               |
// | If you did not receive a copy of the PHP license and are unable to     |
// | obtain it through the world-wide-web, please send a note to            |
// | license@php.net so we can mail you a copy immediately.                 |
// +------------------------------------------------------------------------+
// | Author:                                                                |
// +------------------------------------------------------------------------+
//
// $Id$
//


/**
 * @author       dehua
 */
class PdoRecordSet extends RecordSet {
    
    /**
     * @var      PDOStatement
     */
    protected $_stmt;
    protected $_sql;
    
    /**
     * @var      int
     */
    protected $_fetchMode = PDO::FETCH_ASSOC;
    
    public function __construct($stmt, $sql) {
        $this->_stmt = $stmt;
        $this->_sql = $sql;
        $this->_stmt->setFetchMode($this->_fetchMode);
    }
    
    /**
     * @param    int $style    
     * @return   array
     */
    public function fetch($style = null) {
        return $this->_stmt->fetch();
    }
    
    /**
     * @param    int $style    
     * @return   array
     */
    public function fetchAll($style = null) {
        return $this->_stmt->fetchAll();
    }
    
    public function fetchColumn($column_number = null) {
        return $this->_stmt->fetchColumn($column_number);
    }
    
    /**
     * @return   int
     */
    public function rowCount() {
        return $this->_stmt->rowCount();
    }
    
    /**
     * @return   int
     */
    public function columnCount() {
        return $this->_stmt->columnCount();
    }
    
    /**
     * @return   boolean
     */
    public function free() {
        return $this->_stmt->closeCursor();
    }
}

?>